<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="<c:url value='/css/bootstrap.css' />" rel="stylesheet">
<title>Money for nothing - Account Details</title>
</head>
<body>
	<%@include file="logbar.jsp"%>
	<div class="container offset-content">
		<%@include file="title.jsp"%>
		<div class="span12 subnav">
			<ul class="pagination">
				<li><a href="<c:url value="/" />">Home</a></li>
				<li class="active"><a href="<c:url value='/accounts'/>">Accounts</a></li>
				<li><a href="<c:url value='/transfers/generate'/> ">Transfers</a></li>
			</ul>
			<ul class="breadcrumb">
				<li><a href="<c:url value='/accounts'/>">Accounts</a> <span
					class="divider">/</span></li>
				<li class="active"><a href="#">${account.accountName}</a></li>
			</ul>
		</div>
		<div class="span3 alert alert-info">
			<h4 class="alert-heading">Account : ${account.accountName}</h4>
			<c:choose>
				<c:when test='${account.accountAmount < "0"}'>
					<h4 class="alert-heading amount">Balance :
						${account.accountAmount} $</h4>
				</c:when>
				<c:otherwise>
					<h4 class="alert-heading">Balance : ${account.accountAmount} $</h4>
				</c:otherwise>
			</c:choose>
		</div>
		<div class="span8 offset2">
			<ul class="pagination">
				<c:forEach items="${listDatesLastSixMonth}" var="date">
					<c:choose>
						<c:when
							test="${date.getMonthOfYear().equals(currentDate.getMonthOfYear())}">
							<li class="active"><a
								href="<c:url value='/accounts/${account.accountName}/${date.getYear()}/${date.getMonthOfYear()}/1' />">${date.toString("MMMM
									yyyy", Locale.ENGLISH)}</a></li>
						</c:when>
						<c:otherwise>
							<li><a
								href="<c:url value='/accounts/${account.accountName}/${date.getYear()}/${date.getMonthOfYear()}/1' />">${date.toString("MMMM
									yyyy", Locale.ENGLISH)}</a></li>
						</c:otherwise>
					</c:choose>
				</c:forEach>
			</ul>
		</div>

		<fieldset class="span12">
			<legend>Transactions : ${currentDate.toString("MMMM yyyy",
				Locale.ENGLISH)}</legend>
			<p>You have ${nbResults} transaction(s) for this month.</p>
			<table class="table table-striped">
				<thead>
					<tr>
						<th>Date</th>
						<th>Type</th>
						<th>Label</th>
						<th>Amount ($)</th>
					</tr>
				</thead>
				<tbody>
					<c:if test="${not empty cardTransactions}">
						<tr>
							<td>${cardTransactions.printDate()}</td>
							<td><a
								href="<c:url value='/accounts/${account.accountName}/card/${currentDate.getYear()}/${currentDate.getMonthOfYear()}/1' />">CARD</a>
							</td>
							<td>${cardTransactions.printLabel()}</td>
							<c:choose>
								<c:when test='${cardTransactions.transactionAmount < "0"}'>
									<td class="amount">${cardTransactions.transactionAmount}</td>
								</c:when>
								<c:otherwise>
									<td>${cardTransactions.transactionAmount}</td>
								</c:otherwise>
							</c:choose>
						</tr>
					</c:if>
					<c:forEach items="${transactionsList}" var="oneTransaction">
						<tr>
							<td>${oneTransaction.printDate()}</td>
							<td>${oneTransaction.getTransactionType()}</td>
							<td>${oneTransaction.printLabel()}</td>
							<c:choose>
								<c:when test='${oneTransaction.transactionAmount < "0"}'>
									<td class="amount">${oneTransaction.transactionAmount}</td>
								</c:when>
								<c:otherwise>
									<td>${oneTransaction.transactionAmount}</td>
								</c:otherwise>
							</c:choose>
						</tr>
					</c:forEach>
				</tbody>
			</table>
		</fieldset>

		<c:if test="${nbPages != 1}">
			<div class="span4 offset4">
				<ul class="pagination">
					<c:forEach var="onePage" begin="1" end="${nbPages}">
						<c:choose>
							<c:when test="${onePage eq page}">
								<li class="active"><a
									href="<c:url value='/accounts/${account.accountName}/${currentDate.getYear()}/${currentDate.getMonthOfYear()}/${onePage}' />">${onePage}</a></li>
							</c:when>
							<c:otherwise>
								<li><a
									href="<c:url value='/accounts/${account.accountName}/${currentDate.getYear()}/${currentDate.getMonthOfYear()}/${onePage}' />">${onePage}</a></li>
							</c:otherwise>
						</c:choose>
					</c:forEach>
				</ul>
			</div>
		</c:if>
		
		

		<%@include file="footer.jsp"%>
	</div>
</body>
</html>